<link href="static/css/general.css" type="text/css" rel="stylesheet"/>
<link href="static/css/register.css" rel="stylesheet" type="text/css" />
<script src="static/js/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="static/css/jquery.theme.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.core.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.datepicker.css" media="all" />

        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.button.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.resizable.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.dialog.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.tooltip.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.tooltip.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.menu.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.override.css" media="all" />

        <link rel="stylesheet" type="text/css" href="static/css/user-own.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/profile.css" media="all" />
        <script type='text/javascript' src='static/js/menu.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.core.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.widget.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.datepicker.js'></script>

        <script type='text/javascript' src='static/js/jquery.ui.button.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.draggable.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.mouse.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.position.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.resizable.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.dialog.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.tooltip.js'></script>
		<script type="text/javascript" src="static/js/jqueryValidation.js"></script>
		<script type="text/javascript" src="static/js/renderdate.js"></script>
		<script>

		$(document).ready(function(){
	        $day.init();
	        //$validation.init();
		        $("#registration_form").validate();
		        $('#registration_form').submit(function(){
		        	$('label.error').prepend('<br />');

		        	alert($('#password_check').val());
		        	if($('#password_check').val() == ''){
			        	alert('This field is required');
		        		//$('#password_check').text('This field is required');
		        		return false;
		        	}
		        	else{
		        		if($('#password_heck').val() != $('#password').val()){
			        		alert('Passwordc not match');
		        			//$('#password_check').text('Password not match');
		        			return false;
			        	}
		        	}
		    	});

		    	$('#refresh').click(function(){
			    	$('#captcha_image').attr("src", "index.php?c=register&m=createcaptcha");
			    });

		});
</script>
<div class='reg'>
    <div class='header'>Registration</div>
    <style type='text/css'>
        a.cancel { text-decoration: none;}
    </style>
    <div class='main'>
        <form action='index.php?c=register' method='post' id='registration_form' name='registration_form'>
            <table>
                <tr>
                    <td colspan='2'><span class='error'><?php echo!empty($this->error) ? $this->error : ''; ?></span></td>
                </tr>
                <tr>
                    <td>
                        <label for='name'>Fullname:</label>
                    </td>
                    <td>
                        <input type='input' name='user[name]' id='name' value='<?php echo !empty($this->userReg) ? $this->userReg->name : ''; ?>' class="required" minlength="4"  size='28'  />
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for='username'>Username:</label>
                    </td>
                    <td>
                        <input type='input' name='user[username]' id='user_name' value='<?php echo !empty($this->userReg) ? $this->userReg->username : ''; ?>' class="required" minlength="4" size='28'  />
                    </td>
                </tr>
                <tr>
                    <td><label for='password'>Password:</label>
                    </td>
                    <td>
                        <input type='password' name='user[password]' id='password' value='' class="required" minlength="4"  size='28' /></td>
                </tr>
                <tr>
                    <td><label for='repassword'>Re-password:</label>
                    </td>
                    <td>
                        <input type='password' name='user[repassword]' id='repassword' size='28' />
                        <label id='password_check' for="repassword" generated="true" class="error"><br></label>
                    </td>
                </tr>
                 <tr>
                    <td><label for='email'>Email:</label>
                    </td>
                    <td>
                        <input type='text' name='user[email]' id='email' value='<?php echo !empty($this->userReg) ? $this->userReg->email : ''; ?>' class="required email" minlength="4"  size='28' /></td>
                </tr>
                <tr>
                    <td><label for='email'>Address:</label>
                    </td>
                    <td>
                    	<textarea  name='user[address]' id='address' cols='24' ><?php echo !empty($this->userReg) ? $this->userReg->address : ''; ?></textarea >
                     </td>
                </tr>
                <tr>
                    <td><label for='birthday'>Birthday:</label>
                    </td>
                    <td>
						<select id='month' name='user[month]'>
							<?php foreach ($this->month as $key=>$val): ?>
								<option
								<?php
									if(!empty($this->userReg)){
										echo $key == $this->userReg->month ? "selected='selected'" : '';
									}
								?>
								value='<?php echo $key; ?>'><?php echo $val; ?></option>
							<?php endforeach; ?>
						</select>
						<select id='day' name='user[day]'>
							<?php foreach ($this->day as $key=>$val): ?>
								<option
								<?php
									if(!empty($this->userReg)){
										echo $key == $this->userReg->day ? "selected='selected'" : '';
									}
								?>
								 value='<?php echo $key; ?>'><?php echo $val; ?></option>
							<?php endforeach; ?>
						</select>
						<select id='year' name='user[year]'>
							<?php foreach ($this->year as $key=>$val): ?>
								<option
								<?php
									if(!empty($this->userReg)){
										echo $key == $this->userReg->year ? "selected='selected'" : '';
									}
								?>
								 value='<?php echo $key; ?>'><?php echo $val; ?></option>
							<?php endforeach; ?>
						</select>
                    </td>
                </tr>
                <tr>
                	<td>
                        <label for='Sex'>Sex:</label>
                    </td>
                    <td>
                        <input type='radio' name='user[sex]' id='sex_male' value='1' <?php echo !empty($this->userReg) ? ($this->userReg->sex == 1 ? 'checked="checked"' : '') : 'checked="checked"'; ?> />Male
                        <input type='radio' name='user[sex]' id='sex_female' value='2' <?php echo !empty($this->userReg) ? ($this->userReg->sex == 2 ? 'checked="checked"' : '') : ''; ?> />Female
                    </td>
                </tr>
				 <tr>
				 	<td></td>
                    <td>
                    	<img id="captcha_image" src="index.php?c=register&m=createcaptcha"/><br /><br />
                    	<input type='text' id='captcha' name='user[captcha]' size='28' value = '' width='100px' class='required' />
                    </td>
                </tr>
                <tr>
                    <td><input type='submit' name='user[register]' id='register' value='Register' /></td>
                    <td><input type='reset' name='user[reset]' id='reset' value='Reset' />&nbsp;&nbsp;&nbsp;<a href="index.php?c=login">Back</a></td>
                </tr>
            </table>
        </form>
    </div>
</div>
